<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" session="false" %>
<%@ page import="com.primeton.cap.AppUserManager"%>
<%@ page import="com.eos.data.datacontext.UserObject"%>
<%@ page import="commonj.sdo.DataObject"%>
<%@ page import="com.eos.engine.component.ILogicComponent"%>
<%@ page import="com.primeton.ext.engine.component.LogicComponentFactory"%>
<%@ page import="com.eos.engine.component.ILogicComponent"%>
<%@page import="com.eos.data.datacontext.UserObject"%>
	
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- 
  - Author(s): houfy
  - Date: 2015-08-01 10:14:03
  - Description:
-->
<head>
	<%@include file="/common.jsp"%>
	<%@include file="/coframe/tools/skins/common.jsp" %>
	<%
		UserObject uo = new UserObject();
		uo = (UserObject)request.getSession().getAttribute("userObject");
		
		// 从userObject取orgUser
		DataObject orgUser = (DataObject)uo.get("orgUser");
		//登录用户ID
		String userid = orgUser.getString("userid");
		//登录用户名
		String empname = orgUser.getString("empname");
		//登录用户所属部门
		String orgname = orgUser.getString("orgname");
		
		// 登录日志追加
		// 登陆者所属BU
		String operatorId = orgUser.getString("operatorid");
		String empId = orgUser.getString("empid");
		String userName=uo.getUserName();
		String ip=(String)uo.getUserRemoteIP();
		Object[] result = null;
		// 逻辑构件名称****
		String componentName = "org.gocom.components.coframe.auth.LoginManager";
		// 逻辑流名称****
		String operationName = "commLogin";  
		ILogicComponent logicComponent = LogicComponentFactory.create(componentName);
		int size = 3;
		//逻辑流的输入参数
		Object[] params = new Object[size];
		params[0] = empId;
		params[1] = userName;
		params[2] = ip;
		try{
		    // 调用逻辑流
			result = logicComponent.invoke(operationName, params);
		}catch(Throwable e){};
	%>				
	<title>科研项目管理系统</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<body class="index">
	<!--Layout-->
	<div id="header" class="nui-layout" style="width:100%;height:100%;">
	    <div region="north" height="80" showSplit="false" showHeader="true">
	        <div class="fl clearfix">
				<h1 class="logo"></h1>
				<h2 class="name">科研项目管理系统</h2>
			</div>
	        <div class="options fr" style="position:absolute;top:20px;right:5px;">
	            <div class="time font-5">
					<span class="font-1">您好，<%=userid%>_<%=empname%></span>&nbsp;&nbsp;
					<span class="font-1">所属部门：<%=orgname%></span>&nbsp;&nbsp;
					<span id="currentData"></span>&nbsp;&nbsp;
					<span class="font-1"><a class="set" href="#" onclick="modifyPsw()">修改密码</a></span>&nbsp;&nbsp;
					<span class="font-1"><a class="login-out" href="<%=contextPath%>/coframe/auth/login/logout.jsp" target="_top">注销</a></span>
	        	</div>
	        </div>
	    </div>
	    
	    <div title="center" region="center" style="border:0;" bodyStyle="overflow:hidden;">
	        <!--Splitter-->
	        <div class="nui-splitter" style="width:100%;height:100%;" borderStyle="border:0;">
	            <div size="200" maxSize="250" minSize="150" showCollapseButton="true" style="border:0;">
	                <!--OutlookTree-->
	                <div id="leftTree" class="nui-outlooktree" url="org.gocom.components.coframe.auth.LoginManager.getMenuData.biz.ext?menuSource=default" onnodeclick="onNodeSelect"
	                    textField="menuName" idField="menuPrimeKey" parentField="parentPrimeKey" resultAsTree="false"
	                    showTreeIcon="true" dataField="treeNodes">
	                </div>
	            </div>
	            <div showCollapseButton="false" style="border:0;">
	                <!--Tabs-->
	                <div id="hometabs" class="nui-tabs" activeIndex="0" style="width:100%;height:100%;" contextMenu="#tabsMenu">
	                    <div id="dbtab" name="homePage" title="首页" url="<%=contextPath%>/mis/message/message.jsp"></div>
	                </div>
	            </div>        
	        </div>
	    </div>
	</div>
	
	<ul id="tabsMenu" class="mini-contextmenu" onbeforeopen="onBeforeOpen">        
        <li onclick="closeTab">关闭当前标签页</li>                
	    <li onclick="closeAllBut">关闭其他标签页</li>
	    <li onclick="closeAll">关闭所有标签页</li>        
        <li onclick="closeAllButFirst">关闭其他标签页[首页除外]</li>   
    </ul>
 
    <script type="text/javascript">
        nui.parse();
        
        var contextPath = "<%=contextPath%>";
 
        var tree = nui.get("leftTree");        
        // 多tab页签
		var tabs = nui.get("hometabs");
        
        // 系统时间
        var date = new Date();
		var currentDate = date.getFullYear() + "年" + (date.getMonth()+ 1) + "月" + date.getDate() + "日";
		$("#currentData").text(currentDate);	
		
		// add by houfy 20160130 begin
		// 通过右键菜单关闭tab页签
		var currentTab = null;

        function onBeforeOpen(e) {
            currentTab = tabs.getTabByEvent(e.htmlEvent);
            if (!currentTab) {
                e.cancel = true;                
            }
        }
		
		// 关闭当前标签页
        function closeTab() {
            tabs.removeTab(currentTab);
        }
        
        // 关闭其他标签页
        function closeAllBut() {
            tabs.removeAll(currentTab);
        }
        
        // 关闭所有标签页
        function closeAll() {
            tabs.removeAll();
        }
        
        // 关闭其他标签页[首页除外]
        function closeAllButFirst() {
            var but = [currentTab];            
            but.push(tabs.getTab("homePage"));
            tabs.removeAll(but);
        }
        // add by houfy 20160130 end
		
		// 修改密码
		function modifyPsw(){
			nui.open({
    			url: "<%=contextPath%>/coframe/rights/user/update_password.jsp",
    			title:"修改密码",
    			width: "370px",
    			height: "200px"
    		});
		}
 
 		// 菜单点击
        function onNodeSelect(e) {
            var item = e.node;
            var url = item.linkAction;
            var title = item.menuName;
            //add by sunsl 20140923 begin
	    	var name="";
	    	if(url !=null && url != ""){
	    		if(url.indexOf("/")>=0){
			    	var nameArray = url.split("/");
			    	name= nameArray[nameArray.length-1];
			    	name= name.substr(0,name.indexOf("."));
		    	}
		    	else{
		    		name=url;
		    	}
	    	}
	    	//add by sunsl 20140923 end
	    	
	    	var relative = url.substr(0,1);
			if(relative == "/"){
				url = contextPath + url;
			}
	    	//add by houfy 20140920 end
            addtabs(url, title, name);
        }
	
		// 跳转,新增tab页
		function addtabs(url, title, name) {
			var t = true;
	
			if(title.length > 10)
			{
				title=title.substring(0,9)+"..";
			}
		
			var tab = {name:name, title: title , url: url, showCloseButton: true };
			
			// 获取全部tabs
			var allTab = tabs.getTabs();
	
			for(var k = 0;k<allTab.length;k++){
				if(allTab[k].url == tab.url){
					//若tabs中存在，置标识为false，激活当前
					t = false;
					tabs.activeTab(allTab[k]);
				}
			}
			
			// 若tabs中不存在当前tab，添加
			if(t){
				tabs.addTab(tab);
				//激活 tab
				tabs.activeTab(tab);
			}
		}
	
		// 刷新tab页签
		function refreshTabsAfterAdd(name,data){
			// 根据名称获取tab
			var rTab = tabs.getTab(name);
			// 获取tab的Html Iframe
			var elm = tabs.getTabIFrameEl(rTab);
			if(elm != undefined){
				if(elm.contentWindow != undefined){
					// 调用其js方法
					elm.contentWindow.refreshTabsByName(data);
				}
			}
		}
		
		// 刷新tab页签中的表格
		function refreshGridAfterEdit(name,data){
			// 根据名称获取tab
			var rTab = tabs.getTab(name);
			// 获取tab的Html Iframe
			var elm = tabs.getTabIFrameEl(rTab);
			if(elm != undefined){
				if(elm.contentWindow != undefined){
					// 调用其js方法
					elm.contentWindow.refreshGridByName(data);
				}
			}
		}
		
		// 刷新tab
		function refreshTab(tabName){
			// 根据名称获取tab
			var rTab = tabs.getTab(tabName);
			if(rTab){
				// 属性tab
				tabs.reloadTab(rTab);
			}
		}
		
    </script>
	
</body>
</html>